/**
 *	\file
 *	\brief represents the lexical token read from the source file by yylex()
 *
 * 	\date Jul 20, 2013
 * 	\author koldar
 */

#ifndef LEXVAL_H_
#define LEXVAL_H_

#include <stdio.h>

/**value to insert in printLexVal() if you want inteprets lexval as a integer*/
#define LEXVAL_INTEGER_MEANING 0
/**value to insert in printLexVal() if you want inteprets lexval as a string*/
#define LEXVAL_STRING_MEANING 1
/**value to insert in printLexVal() if you don't want intepreter lexval at all*/
#define LEXVAL_NIHIL_MEANING 2
/**value to insert in printLexVal() if you want inteprets lexval as a boolean*/
#define LEXVAL_BOOLEAN_MEANING 3

/**it represents a single lexical token read from the source file
 *
 */
typedef union LexVal {
	/**holds the integer value of the token. It has sense only if the symbol is:
	 * \li a numconst;
	 * \li a boolconst;
	 * \li a reserved word;
	 * \li a sugar;
	 * */
	int ival;
	/**holds the string representation of this token. It has sense only if the symbol is:
	 * \li a identifier;
	 * */
	char* sval;
} LexVal;

/**indicates a lexical value with the union data set to 0*/
#define LEXVAL_NULL (LexVal){0}

/**prints on a file the value of the current lexval structure. Being a union, this object needs
 * a variable to understands exactly how to interpret the data contained. This variable is meaning;
 * for example let obj contain the data 17456. This can be interpreted as:
 * \li the number 17456 by writing obj.ival;
 * \li the address 17456 by writing obj.sval: in this scenario the computer will write "hello world!" (string
 * contained in the address 17456);
 *
 * the variable meaning is necessary to understand the very meaning of the lexval.
 *
 * @param f the file to write the string representation
 * @param obj the Lexical value to be written
 * @param meaning the meaning of the value stored in obj. The value can be one of these list:
 * 	\li LEXVAL_INTEGER_MEANING for an intenger value;
 * 	\li LEXVAL_BOOLEAN_MEANING for a "true" "false" value;
 * 	\li LEXVAL_STRING_MEANING for a string value;
 * 	\li LEXVAL_NIHIL_MEANING for no meaning at all;
 *
 */
void printLexVal(FILE* f,LexVal obj,int meaning);

#endif /* LEXVAL_H_ */
